package com.hcrazy.manchester.app.services;

import org.joda.time.DateTime;

import com.hcrazy.manchester.app.jdbc.FeedbackDAO;
import com.hcrazy.manchester.app.pojo.Feedback;
import com.hcrazy.manchester.app.pojo.PageModel;

public class FeedbackService {
	
	private FeedbackDAO feedbackDAO;

	public FeedbackDAO getFeedbackDAO() {
		return feedbackDAO;
	}

	public void setFeedbackDAO(FeedbackDAO feedbackDAO) {
		this.feedbackDAO = feedbackDAO;
	}

	public void addFeedback(String phone,String email,String name,String content,long userId) throws Exception{
		Feedback fb = new Feedback();
		fb.setContent(content);
		fb.setCreateTime(new DateTime().toString("yyyy-MM-dd HH:mm:ss"));
		fb.setEmail(email);
		fb.setName(name);
		fb.setPhone(phone);
		fb.setUserId(userId);
		feedbackDAO.addFeedback(fb);
	}
	
	public void addFeedback(Feedback feedback) throws Exception{
		feedbackDAO.addFeedback(feedback);
	}
	
	public PageModel getPagedFeedbacks(PageModel model) throws Exception{
		return feedbackDAO.getPagedFeedbacks(model);
	}
	
	public Feedback getById(long feedbackId) throws Exception{
		return feedbackDAO.getById(feedbackId);
	}
	
	public void delFeedback(int feedbackId) throws Exception{
		feedbackDAO.delFeedback(feedbackId);
	}
}
